<?php
require_once("bootstrap.php");
  class request_review
  {
      var $request_id;
      var $req;
      var $xml_request;
      
      public function request_review($request_id)
      {
          $this->request_id=$request_id;
          $this->req=Doctrine::getTable('Requests')->find($this->request_id);
          $this->build_request($this->req);
      }
      
      public function view_req()
      {
          return $this->xml_request;
      }
      
      private function build_request($arr)
      {
          $str="<ns1:ProviderTransaction xmlns:ns1='xxs'><REQ><PSC5>";
          $opt_arr=explode(",",$arr->options);
          foreach($opt_arr as $opt){
          $str.="<OPT>$opt</OPT>";  
          }
          if($this->search_type=="RT")
          {
              $str.="<OPT>F</OPT>";
          }
          $str.="<POI_ORI><CIT>DEP</CIT></POI_ORI>";
          $str.="<NUM_ALT>".$arr->num_alt."</NUM_ALT>";
          $inc_arl_arr=explode(",",$arr->inc_arl);
          $exc_arl_arr=explode(",",$arr->exc_arl);
          if(count($inc_arl_arr)>=1&&$arr->inc_arl!=''||count($exc_arl_arr)>=1&&$arr->exc_arl!='')
          {
              $str.="<ARL_INF>";
              if(count($exc_arl_arr)>0)
              {
                  $str.="<EXC_ARL>";
                  foreach($exc_arl_arr as $inc)
                  {
                      $str.="<ARL_COD>".$inc."</ARL_COD>";
                  }
                  $str.="</EXC_ARL>";
              }
              if(count($inc_arl_arr)>0)
              {
                  $str.="<ARL_OPT>".$arr->arl_opt."</ARL_OPT>";
                  foreach($inc_arl_arr as $exc)
                  {
                      $str.="<ARL_COD>".$exc."</ARL_COD>";
                  }
                  
              }
            $str.="</ARL_INF>";  
          }
          
          if($this->search_type=="RT")
          {
              $str.="<REG_RET_DAT>17APR</REG_RET_DAT>";
          }
        $ptc_arr=explode(",",$arr->ptc);
        $ptc = "<PTC_INF><NUM_PAX>1</NUM_PAX><PTC>$ptc_arr[0]</PTC></PTC_INF>";
        $ptc .= "<PTC_INF><NUM_PAX>1</NUM_PAX><PTC>$ptc_arr[1]</PTC></PTC_INF>";
        $ptc .= "<PTC_INF><NUM_PAX>1</NUM_PAX><PTC>$ptc_arr[2]</PTC></PTC_INF>";
        $str.=$ptc;
        $str.="<DES_INF><DEP_DAT>12APR</DEP_DAT><DEP_TIM>1200</DEP_TIM><CAB_CLA>Y</CAB_CLA><POI_DES><CIT>DES</CIT></POI_DES></DES_INF>";
        $str.="</PSC5></REQ></ns1:ProviderTransaction>";
        $header="<t:Transaction xmlns:t='xxs'><tc><iden u='ett' p='ett0000' /><provider session='W1XML' pcc='".$arr->sid."'>Worldspan</provider><trace></trace></tc></t:Transaction>";
        $soap_env_top='<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header>'.$header.'</SOAP-ENV:Header><SOAP-ENV:Body>'.$str.'</SOAP-ENV:Body></SOAP-ENV:Envelope>';
        $this->xml_request=$soap_env_top;
      }
      
  }
?>
